package com.myapp.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import com.myapp.service.EmpService;

@Controller
public class EmpController {

	@Autowired
	private EmpService empService;
	
	@RequestMapping(value="/emp/count.do", method=RequestMethod.GET)
	public String getEmpCount(Model model, HttpServletRequest request) {
		System.out.println(request.getParameter("data"));
		model.addAttribute("count", empService.getAllEmpCount());
		return "emp/count";
	}
	
	@RequestMapping(value="/emp/select.do")
	public String getEmp(@RequestParam int empno, Model model) {
		model.addAttribute("emp", empService.selectEmp(empno));
		return "emp/select";
	}
}
